package cn.hzu580.action;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import cn.hzu580.entity.Mission;
import cn.hzu580.service.MissionService;
import cn.hzu580.vo.MissionVO;

@Controller
@Scope("prototype")
public class MissionAction extends ActionSupport implements ModelDriven<MissionVO> {

	private InputStream inputStream;
	
	@Resource(name="mission")
	private MissionService missionService;
	
	private MissionVO missionVO;

	private Mission json;
	
	private List<Mission> jsonArray;
	
	private Map<String, Object> jsonMap;

	public void create() throws Exception{
		missionService.create(missionVO);
	}


	public String get() throws Exception{
		json = missionService.get(missionVO);
		return "json";
	}


	public String listMain() throws Exception{
		jsonArray = missionService.listMain(missionVO);
		return "json_array";
	}
	
	
	public String listMine() throws Exception{
		jsonArray = missionService.listMine();
		return "json_array";
	}


	public void cancel() throws Exception{
		missionService.cancel(missionVO);
	}


	public void start() throws Exception{
		missionService.start(missionVO);
	}


	public void finish() throws Exception{
		missionService.finish(missionVO);
	}


	public void delete() throws Exception{
		missionService.delete(missionVO);
	}


	public String count() throws Exception{
		jsonMap = missionService.count(missionVO);
		return "json_map";
	}


	public String listHelp() throws Exception{
		jsonArray = missionService.listHelp(missionVO);
		return "json_array";
	}


	public String listBeHelp() throws Exception{
		jsonArray = missionService.listBeHelp(missionVO);
		return "json_array";
	}
	
	
	
	public InputStream getInputStream() {
		return inputStream;
	}



	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}



	public MissionService getMissionService() {
		return missionService;
	}



	public void setMissionService(MissionService missionService) {
		this.missionService = missionService;
	}



	public MissionVO getMissionVO() {
		return missionVO;
	}



	public void setMissionVO(MissionVO missionVO) {
		this.missionVO = missionVO;
	}



	@Override
	public MissionVO getModel() {
		missionVO = new MissionVO();
		return missionVO;
	}


	public Mission getJson() {
		return json;
	}


	public void setJson(Mission json) {
		this.json = json;
	}


	public List<Mission> getJsonArray() {
		return jsonArray;
	}


	public void setJsonArray(List<Mission> jsonArray) {
		this.jsonArray = jsonArray;
	}


	public Map<String, Object> getJsonMap() {
		return jsonMap;
	}


	public void setJsonMap(Map<String, Object> jsonMap) {
		this.jsonMap = jsonMap;
	}
	
	
	
}
